using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Input;
using UserManager.Commands;
using UserManager.Models;
using UserManager.Views;

namespace UserManager.ViewModel;

public class MainViewModel
{
    public ObservableCollection<User> Users { get; set; }
    
    public ICommand ShowWindowCommand { get; set; }

    public MainViewModel()
    {
        Users = UserManagerRep.GetUsers();
        ShowWindowCommand = new RelayCommand(ShowWindow,CanShowWindow);
    }

    private bool CanShowWindow(object obj)
    {
        return true;
    }

    private void ShowWindow(object obj)
    {
        var mainWindow = obj as Window;
        
        var window = new AddUser();
        window.Owner = mainWindow;
        window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
        window.Show();
    }
}